package com.studycloud.controller;

import com.studycloud.service.PaymentFeignService;
import com.studyclud.entity.Payment;
import com.studyclud.result.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * @author JP
 */
@RestController
@Slf4j
public class OrderController
{
    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/consumer/payment/create")
    public CommonResult<Integer> create(Payment payment)
    {
        return paymentFeignService.create(payment);
    }

    /**
     * 使用 => getForObject
     * @param id
     * @return
     */
    @GetMapping(value = "/consume/payment/getPaymenById/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id)
    {
        return paymentFeignService.getPaymenById(id);
    }

    /**
     *
     * @return
     */
    @GetMapping(value = "/consume/payment/feign/timeout")
    public String paymentFeignTimeout()
    {
        //openfeign0ribbon , 客户端一般默认等待1秒钟
        return paymentFeignService.paymentFeignTimeout();
    }

}
